﻿using System;
using System.Collections.Generic;
using System.Security.Principal;
using System.Text;

namespace MSATracert
{
#pragma warning disable CS1591
    public class LinkTracertPricipal : IPrincipal
    {
        public const string HEADER_NAME = "X-Connection-Id";
        private readonly IPrincipal oriPrincipal;
        public LinkTracertPricipal(string traceId, IPrincipal principal)
        {
            this.RequestId = traceId;
            this.oriPrincipal = principal;
            this.Tokens = new List<ApiToken>();
        }
        public string RequestId { get; set; }
        public string IPAddress { get; set; }
        public List<ApiToken> Tokens { get; private set; }
        public IIdentity Identity => this.oriPrincipal?.Identity;

        public bool IsInRole(string role)
        {
            return this.oriPrincipal == null ? false : this.oriPrincipal.IsInRole(role);
        }
    }

    public class ApiToken
    {
        public string Name { get; set; }
        public string Value { get; set; }
    }
#pragma warning restore CS1591
}
